package com.business.systemmanage.service.Impl;

import com.business.systemmanage.common.cont.CommonCont;
import com.business.systemmanage.entity.Organ;
import com.business.systemmanage.mapper.OrganMapper;
import com.business.systemmanage.service.IOrganService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.business.systemmanage.vo.OrganVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * <p>
 * 组织机构 服务实现类
 * </p>
 *
 * @author sixDog
 * @since 2019-04-12
 */
@Service
public class OrganServiceImpl extends ServiceImpl<OrganMapper, Organ> implements IOrganService {

    @Override
    public void insert(OrganVO organVO) {
        Organ organ = new Organ();
        BeanUtils.copyProperties(organVO,organ);
        if(organ.getFatherId()==0) {
            organ.setIsParent(CommonCont.YES);
        } else {
            organ.setIsParent(CommonCont.NO);
        }
        organ.setStatus(CommonCont.YES);
        organ.setCreateTime(LocalDateTime.now());
        organ.setModifyTime(LocalDateTime.now());
        this.save(organ);
    }
}
